import { AfterContentInit, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';

@Component({
  selector: 'app-lifecycle',
  templateUrl: './lifecycle.component.html',
  styleUrls: ['./lifecycle.component.less']
})
export class LifecycleComponent implements OnChanges,OnInit,AfterContentInit{
  @Input() name:string = "";
  @Input() age:number = 0;
  @Input("options") options:Array<any> = [];
  constructor(){
    console.log("1 constructor");
  }
  ngOnChanges(changes: SimpleChanges): void {
    console.log(changes,"初始设置时也会执行");
    console.log("ngOnChanges");
  }
  ngOnInit(): void {
    console.log("2 ngOnInit");
  }
  ngAfterContentInit(): void {
    console.log("3 ngAfterContentInit");
  }
  ngOnDestroy(){
    console.log("ngOnDestroy");
  }
}
